/**
 * @mbggenerated
 * @author wujian
 */
package bearworker.zxl.dao.mapper;

import bearworker.zxl.entity.WxUserTicket;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

public interface WxUserTicketMapper {
    /* @mbggenerated */
    @Delete({
        "delete from wx_user_ticket",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    /* @mbggenerated */
    @Insert({
        "insert into wx_user_ticket (open_id, scene_str, ",
        "ticket, expire_time, ",
        "create_time)",
        "values (#{openId,jdbcType=VARCHAR}, #{sceneStr,jdbcType=VARCHAR}, ",
        "#{ticket,jdbcType=VARCHAR}, #{expireTime,jdbcType=TIMESTAMP}, ",
        "#{createTime,jdbcType=TIMESTAMP})"
    })
    @Options(useGeneratedKeys=true,keyProperty="id")
    int insert(WxUserTicket record);

    /* @mbggenerated */
    @InsertProvider(type=WxUserTicketSqlProvider.class, method="insertSelective")
    @Options(useGeneratedKeys=true,keyProperty="id")
    int insertSelective(WxUserTicket record);

    /* @mbggenerated */
    @Select({
        "select",
        "id, open_id, scene_str, ticket, expire_time, create_time",
        "from wx_user_ticket",
        "where expire_time > now() and open_id = #{openId,jdbcType=VARCHAR}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="open_id", property="openId", jdbcType=JdbcType.VARCHAR),
        @Result(column="scene_str", property="sceneStr", jdbcType=JdbcType.VARCHAR),
        @Result(column="ticket", property="ticket", jdbcType=JdbcType.VARCHAR),
        @Result(column="expire_time", property="expireTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP)
    })
    WxUserTicket selectByOpenId(@Param("openId") String openId);

    /* @mbggenerated */
    @UpdateProvider(type=WxUserTicketSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(WxUserTicket record);

    /* @mbggenerated */
    @Update({
        "update wx_user_ticket",
        "set open_id = #{openId,jdbcType=VARCHAR},",
          "scene_str = #{sceneStr,jdbcType=VARCHAR},",
          "ticket = #{ticket,jdbcType=VARCHAR},",
          "expire_time = #{expireTime,jdbcType=TIMESTAMP},",
          "create_time = #{createTime,jdbcType=TIMESTAMP}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(WxUserTicket record);
}